@extends('backend.layouts.app')

@section('content')
<div class="layui-card">
    <div class="layui-card-header layui-card-header-auto">订单列表</div>
    <div class="layui-card-body">
        <div class="layui-row" style="margin-bottom:10px">
            <div class="layui-col-md9">
                <div class="laui-form-item">
                    <div class="layui-inline">
                        <select id="paystatus" onchange="search()" class="layui-select">
                            <option value="">全部</option>
                            <option value="paid">已付款</option>
                            <option value="unpaid">未付款</option>
                            <option value="refunded">已退款</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <select id="fee" onchange="search()" class="layui-select">
                            <option value="">全部</option>
                            <option value="0">免费</option>
                            <option value="1">收费</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <input type="text" id="key" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm" onclick="search()">搜索</button>
                    </div>
                </div>
            </div>
            <div class="layui-col-md3">
                <div class="layui-btn-group" style="float:right">
                </div>
            </div>
        </div>
        <table lay-filter="dataTable" id="dataTable">
        </table>
    </div>
</div>
@endsection

@section('script')
<script type="text/javascript">
    let dataTable;
    layui.use(['layer', 'form', 'table'], function () {
        let layer = layui.layer;
        let form = layui.form;
        let table = layui.table;

        dataTable = table.render({
            elem: '#dataTable',
            url: "{{route('admin.business.unified.order.list')}}",
            where: {
                type: '{{$type}}',
                paystatus: $('#paystatus').val(),
                fee: $("#fee").val(),
                key: $('#key').val()
            },
            page: true,
            cols: [
                [{
                    title: '编号',
                    field: 'id',
                    width: 100
                }, {
                    title: '主题',
                    field: 'subject',
                    width: 150
                }, 
                // {
                //     title: '姓名',
                //     field: 'user_true_name'
                // }, 
                {
                    title: '学校',
                    field: 'user_school_name'
                }, {
                    title: '专业',
                    field: 'user_major_name'
                }, {
                    title: '年级',
                    field: 'user_grade_name'
                }, {
                    title: '学历',
                    field: 'user_degree_name'
                }, {
                    title: '手机号',
                    field: 'user_contact_phone'
                }, {
                    title: '创建时间',
                    field: 'create_at'
                }, {
                    title: '总价',
                    field: 'total_fee',
                    templet: function (res) {
                        return res.total_fee / 100;
                    }
                }, {
                    title: '来源',
                    field: 'come_from_name'
                }, {
                    title: '支付状态',
                    field: 'pay_status_name'
                }]
            ]
        });
    });

    function search() {
        dataTable.reload({
            where: {
                type: '{{$type}}',
                paystatus: $('#paystatus').val(),
                fee: $("#fee").val(),
                key: $('#key').val()
            },
            page: {
                curr: 1
            }
        });
    }

</script>
@endsection
